package com.company;

import java.io.*;

public class TestByteArrayToPicture {

    public static void main(String[] args) throws IOException {
        File f = new File("D:/郎印炜/Pictures/Saved Pictures/Saved Pictures/审判者2.jfif");
        InputStream is = new BufferedInputStream(new FileInputStream(f));  //字节缓冲流。
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] b = new byte[1024*10];  //货车搬家，缓冲容器
        byte[] dest = null;
        int len = -1;    //接收长度
        while((len=is.read(b))!=-1){     //判断句，且加了个括号。是因为必须为布尔表达式。
            baos.write(b,0,len);
           //System.out.println(baos.toString());  //打印不断获得的字节翻译而成的字符串。
        }
        baos.flush();
        baos.close();
       byte[] b2= baos.toByteArray();
        System.out.println(b2.length);
       File f2 = new File("tupian.png");
       f2.createNewFile();
       OutputStream os2 = new FileOutputStream(f2);
        os2.write(b2,0,b2.length);
        os2.close();









        }





    }

